﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Global.Class.Library;


namespace DataTransferObject.MetaDataList
{
    public class ListDistributorNameMaster : NotifyPropertyChangeObject
    {
        private int distributorID;

        private DateTime entryDate;

        private int distributorCategoryID;
        private int distributorTypeID;
        private int addressAreaID;
        
        private string description;
        private string descriptionOfficial;
        private string descriptionOriginal;
        private string vatCode;
        private string contactName;
        private string attentionName;
        private string telephone;
        private string eMailAddress;
        private string addressNo;
        private string addressStreet;
        private string other;

        private bool inActive;

        public ListDistributorNameMaster()
        {
            GlobalDefaultValue.Apply(this);
            this.EntryDate = DateTime.Now;
        }

        #region Properties


        [DefaultValue(-1)]
        public int DistributorID
        {
            get { return this.distributorID; }
            set { ApplyPropertyChange<ListDistributorNameMaster, int>(ref this.distributorID, o => o.DistributorID, value); }
        }

        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime EntryDate
        {
            get { return this.entryDate; }
            set { ApplyPropertyChange<ListDistributorNameMaster, DateTime>(ref this.entryDate, o => o.EntryDate, value); }
        }

        [DefaultValue(0)]
        public int DistributorCategoryID
        {
            get { return this.distributorCategoryID; }
            set { ApplyPropertyChange<ListDistributorNameMaster, int>(ref this.distributorCategoryID, o => o.DistributorCategoryID, value); }
        }

        [DefaultValue(0)]
        public int DistributorTypeID
        {
            get { return this.distributorTypeID; }
            set { ApplyPropertyChange<ListDistributorNameMaster, int>(ref this.distributorTypeID, o => o.DistributorTypeID, value); }
        }

        [DefaultValue(0)]
        public int AddressAreaID
        {
            get { return this.addressAreaID; }
            set { ApplyPropertyChange<ListDistributorNameMaster, int>(ref this.addressAreaID, o => o.AddressAreaID, value); }
        }             
        
        [DefaultValue("")]
        public string Description
        {
            get { return this.description; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.description, o => o.Description, value); }
        }

        [DefaultValue("")]
        public string DescriptionOfficial
        {
            get { return this.descriptionOfficial; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.descriptionOfficial, o => o.DescriptionOfficial, value); }
        }

        [DefaultValue("")]
        public string DescriptionOriginal
        {
            get { return this.descriptionOriginal; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.descriptionOriginal, o => o.DescriptionOriginal, value); }
        }

        [DefaultValue("")]
        public string VATCode
        {
            get { return this.vatCode; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.vatCode, o => o.VATCode, value); }
        }

        [DefaultValue("")]
        public string ContactName
        {
            get { return this.contactName; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.contactName, o => o.ContactName, value); }
        }

        [DefaultValue("")]
        public string AttentionName
        {
            get { return this.attentionName; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.attentionName, o => o.AttentionName, value); }
        }

        [DefaultValue("")]
        public string Telephone
        {
            get { return this.telephone; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.telephone, o => o.Telephone, value); }
        }

        [DefaultValue("")]
        public string EMailAddress
        {
            get { return this.eMailAddress; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.eMailAddress, o => o.EMailAddress, value); }
        }

        [DefaultValue("")]
        public string AddressNo
        {
            get { return this.addressNo; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.addressNo, o => o.AddressNo, value); }
        }

        [DefaultValue("")]
        public string AddressStreet
        {
            get { return this.addressStreet; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.addressStreet, o => o.AddressStreet, value); }
        }

        [DefaultValue("")]
        public string Other
        {
            get { return this.other; }
            set { ApplyPropertyChange<ListDistributorNameMaster, string>(ref this.other, o => o.Other, value); }
        }

        [DefaultValue(false)]
        public bool InActive
        {
            get { return this.inActive; }
            set { ApplyPropertyChange<ListDistributorNameMaster, bool>(ref this.inActive, o => o.InActive, value); }
        }
        
        #endregion

        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("Description", "Distributor Code cannot be blank.", delegate { return this.Description.Length != 0; }));
            //validationRules.Add(new SimpleValidationRule("DescriptionOfficial", "Full Description cannot be blank.", delegate { return this.DescriptionOfficial.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("DistributorCategoryID", "Channel cannot be empty.", delegate { return this.DistributorCategoryID > 0; }));
            validationRules.Add(new SimpleValidationRule("AddressAreaID", "Territory cannot be empty.", delegate { return this.AddressAreaID > 0; }));
            validationRules.Add(new SimpleValidationRule("DistributorTypeID", "Distributor Type cannot be empty.", delegate { return this.DistributorTypeID > 0; }));
            
            return validationRules;
        }
    }
}
